home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_tut / onechar.c < prev    next >
C/C++ Source or Header  |  1996-01-30  |  941b  |  31 lines

  1. /*
  2. ONECHAR.C   Ver. 3.00   22-AUG-1994
  3.  
  4. Software Innovations Technology
  5. 1083 Mandarin Drive NE, Palm Bay, FL 32905-4706   (407)951-0233
  6.  
  7. This file is for use with UNIX.ADA.  It is a Unix System V routine to allow
  8. the capture and return of one character from the terminal.
  9.  
  10. This program was written by Dave Hill, 7549 Wynford Street, Salt Lake City, UT
  11. 84121.  Software Innovations Technology is grateful to Mr. Hill for permission
  12. to include ONECHAR.C with ADA-TUTR.
  13. */
  14.  
  15. #include <stdio.h>
  16. #include <termio.h>
  17. char onechar()
  18. {
  19.     static struct termio newsets, oldsets;
  20.     char c;
  21.     ioctl(fileno(stdin), TCGETA, &newsets);
  22.     ioctl(fileno(stdin), TCGETA, &oldsets); /* used by cooked */
  23.     newsets.c_cc[4] = '\001';
  24.     newsets.c_cc[5] = '\0';
  25.     newsets.c_lflag &= ~ (ICANON);
  26.     ioctl(fileno(stdin), TCSETAF, &newsets);
  27.     c = getchar();
  28.     ioctl(fileno(stdin), TCSETAF, &oldsets);
  29.     return (c);
  30. }
  31.